function ObjectSelector(){
	THREE.Raycaster.call(this);
	this.mouse = new THREE.Vector2();
	this.INTERSECTED = new THREE.Object3D();
	this.changed = false;
}

ObjectSelector.prototype = new THREE.Raycaster();
ObjectSelector.prototype.select = function(whoseObjects){
	var that = this;
	// var INTERSECTED;
	whoseObjects.addEventListener( 'mousedown', onDocumentMouseMove, false );

    function onDocumentMouseMove( event ) {
        event.preventDefault();
        that.mouse.x = ( (event.clientX-36) / (window.innerWidth*72/100)) * 2 - 1;
        that.mouse.y = - ( (event.clientY-38) / (window.innerHeight - 38) ) * 2 + 1;
        
        
		that.setFromCamera(that.mouse, camera );
		//这里可以选中既可以有线框又可以有物体的，暂时不这样写
		// for(index in scene.children){
		// 	var intersects = that.intersectObjects( scene.children[index].children);
		// 	// console.log(index);
		// 	if(intersects.length > 0) break;
		// }

		var intersects = that.intersectObjects( scene.children);
		// console.log(intersects[0].point);
		// console.log(intersects[0]);
		// console.log(intersects);
		// console.log(intersects[0].object.point);
		// console.log(intersects[0].object);
	    var i = 0;
	  	if ( intersects.length > 0 ) {

	      	while(i < intersects.length){
	      		if(intersects[ i ].object.name == FORBIDED_NAME){i++;continue;this.changed = false;}
	        	if ( this.INTERSECTED != intersects[ i ].object ) {
	        		this.changed = true;
	          		this.INTERSECTED = intersects[ i ].object;

	          		if(this.INTERSECTED.type == "PointLight" || this.INTERSECTED.type == "AmbientLight"){
	          			if(activeObject.modifier != null && activeObject.modifier.name == "布尔运算"){
	          				if(activeObject.modifier.toPick){
	          					this.INTERSECTED = null;
	          					break;
	          				}
	          			
	          			}
	          			control.attach( intersects[ i ].object.light);
	          			activeObject = intersects[ i ].object.light;
	          			propertyPanel.update();
	          			outliner.update(activeObject.id);
	          			materialPanel.update();
	          			break;
	          		}
	          		if(this.INTERSECTED.type == "DirectionalLight"){
	          			if(activeObject.modifier != null && activeObject.modifier.name == "布尔运算"){
	          				if(activeObject.modifier.toPick){
	          					this.INTERSECTED = null;
	          					break;
	          				}	
	          			}
	          			control.attach( intersects[ i ].object.light);
	          			activeObject = intersects[ i ].object.helper;
	          
	          			propertyPanel.update();
	          			outliner.update(activeObject.light.id);
	          			materialPanel.update();
	          			break;
	          		}
          			if(this.INTERSECTED.type == "SpotLight"){
          				if(activeObject.modifier != null && activeObject.modifier.name == "布尔运算"){
	          				if(activeObject.modifier.toPick){
	          					this.INTERSECTED = null;
	          					break;
	          				}
	          					
	          			}
	          			control.attach( intersects[ i ].object.light);
	          			activeObject = intersects[ i ].object.helper;
	          			// console.log('SpotLight');
	          			propertyPanel.update();
	          			outliner.update(activeObject.light.id);
	          			materialPanel.update();
	          			break;
	          		}
	          		if(this.INTERSECTED.type == "helper"){
	          			if(activeObject.modifier != null && activeObject.modifier.name == "布尔运算"){
	          				if(activeObject.modifier.toPick){
	          					this.INTERSECTED = null;
	          					break;
	          				}
	          					
	          			}
	          			// whoseObjects.addEventListener( 'mousedown', function update(){console.log('sdsdsdsdsdsd')}, false );
	          			control.attach( intersects[ i ].object);
	          			// activeObject = intersects[ i ].object.targetObject;
	          			// propertyPanel.update();
	          			// console.log('SpotLight');
	          			break;
	          		}
	          		if(activeObject.modifier != null && activeObject.modifier.name == "布尔运算"){
	          				// console.log(activeObject.modifier.toPick);
	          				if(activeObject.modifier.toPick){
	          					activeObject.modifier.setTargetObject(this.INTERSECTED);
	          					this.INTERSECTED = null;
	          					break;
	          				}
	          					
	          		}
	          		// console.log('到这里了，没问题');
	          		control.attach( intersects[ i ].object );
	          		activeObject = intersects[ i ].object;

	          		modifierViewer.update();
	          		modifierSelectorViewer.update();

	   				propertyPanel.update();
	   				outliner.update(activeObject.id);
	   				materialPanel.update();
	          		break;	
	        	}
	        	else {
	        		this.changed = false;
	        		break;
	        	}
	      	}
  	    }
    }
    // return INTERSECTED;
}

